import { Injectable } from '@angular/core';
import {BadgeComponent, BadgePipe, SimpleJsonFormatter, SimplePipe} from '../../../ng-tools';
import {DatePipe} from '@angular/common';

@Injectable({
  providedIn: 'root'
})
export class ChargeRecordFormatterService {
    nickname: SimpleJsonFormatter = {propName: 'nickname', displayName: '用户名'};
    fromUserName: SimpleJsonFormatter = {propName: 'fromUserName', displayName: '账户名'};
    toBankName: SimpleJsonFormatter = {propName: 'toBankName', displayName: '银行'};
    toUserName: SimpleJsonFormatter = {propName: 'toUserName', displayName: '银行户名'};
    toSubAddr: SimpleJsonFormatter = {propName: 'toSubAddr', displayName: '分行地址'};
    toNumber: SimpleJsonFormatter = {propName: 'toNumber', displayName: '银行账号'};
    createDate: SimpleJsonFormatter = {propName: 'createDate', displayName: '申请时间'};
    doneDate: SimpleJsonFormatter = {propName: 'createDate', displayName: '完成时间'};
    account: SimpleJsonFormatter = {propName: 'account', displayName: '充值金额'};
  status_display: SimpleJsonFormatter = {propName: 'status_display', displayName: '状态', dynamicComponent: {component: BadgeComponent}, component: BadgeComponent};
    constructor(public badgePipe: BadgePipe, private datePipe: DatePipe) {
      this.status_display.pipe = new SimplePipe(this.badgePipe, [['待审核', '已确认', '已取消'], ['badge-orange', 'badge-success', 'badge-danger']]);
        this.createDate.pipe = new SimplePipe(this.datePipe, ['yyyy-MM-dd HH:mm:ss', null, null, null]);
        this.doneDate.pipe = new SimplePipe(this.datePipe, ['yyyy-MM-dd HH:mm:ss', null, null, null]);
    }
    get formatter() {
        return [
            this.nickname,
            this.fromUserName,
            this.toBankName,
            this.toUserName,
            this.toSubAddr,
            this.toNumber,
            this.createDate,
            this.account,
            this.status_display
        ];
    }

    get doneFormatter() {
        return [
            this.nickname,
            this.fromUserName,
            this.toBankName,
            this.toUserName,
            this.toSubAddr,
            this.toNumber,
            this.doneDate,
            this.account,
            this.status_display
        ];
    }
}
